//
//  InvestmentCell.m
//  DianDangDai
//
//  Created by bhf on 2017/12/13.
//  Copyright © 2017年 bhf. All rights reserved.
//

#import "InvestmentCell.h"

@implementation InvestmentCell

- (void)awakeFromNib {
    [super awakeFromNib];
    //efefef  ffcc00
//    _HUD = [[M13ProgressHUD alloc] initWithProgressView:[[M13ProgressViewRing alloc] init]];
//    _HUD.progressViewSize = CGSizeMake(60.0, 60.0);
//    [_progressView addSubview:_HUD];
//    [_HUD setProgress:1 animated:NO];
//    _ring = [[M13ProgressViewRing alloc] initWithFrame:CGRectMake(0, 0,     _progressView.width, _pgview.height)];
//    [_ring setProgressRingWidth:2];
//    [_ring setBackgroundRingWidth:2];
//    [_ring setPrimaryColor:[UIColor colorWithHex:@"#ffcc00"]];
//    [_ring setSecondaryColor:[UIColor colorWithHex:@"#efefef"]];
//    [_ring setShowContent:NO];
//    [_progressView addSubview:_ring];
//    [_ring setProgress:0.1 animated:NO];
    _investment.layer.cornerRadius = 12;

    // Initialization code
}

- (void)setModel:(InvestmentModel *)model {
    _model = model;
    self.header.text = model.htid;
    self.money.text = [NSString stringWithFormat:@"剩余金额：¥%.2f",model.symoney];
    NSString *str = [NSString stringWithFormat:@"%.1f",model.apr];
    
    NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:[str stringByAppendingString:@"%"]];
    [string addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0] range:NSMakeRange(string.length-1, 1)];
    self.annualYield.attributedText = string;
    NSString *period;
    if (model.period_unit == 1) {
        period = @"天";
    } else if (model.period_unit == 0) {
        period = @"个月";
    } else if (model.period_unit == -1) {
        period = @"年";
    }
    
    self.timeLine.text = [NSString stringWithFormat:@"%ld%@",model.period,period];
    if ([model.strStatus isEqualToString:@"借款中"]) {
        [self.investment setTitle:@"立即投资" forState:UIControlStateNormal];
    } else {
        [self.investment setTitle:model.strStatus forState:UIControlStateNormal];
    }
    if (model.symoney == 0) {
        _yishouqing.hidden = NO;
      
        [_investment setBackgroundImage:nil forState:UIControlStateNormal];
        
    } else if (model.symoney != 0){
        _yishouqing.hidden = YES;
        [_investment setBackgroundImage:[UIImage imageNamed:@"jianbian"] forState:UIControlStateNormal];
    }
    
   // self.annualYield.text = [NSString stringWithFormat:@"%f",model.apr];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
